<template>
    <div class="auth-wrapper">
        <div class='modal'>
            <div class="title">{{title}}</div>
            <div class='logo'>
                <div>{{changeBtnType}}</div>
            </div>
            <button class='loginBtn' @getuserinfo="getUserInfo" open-type="getUserInfo" v-if="changeBtnType === 'login'">微信一键快速登录</button>
            <button class='loginBtn' @click="getPhoneNumber" v-else>获取手机号</button>
            <div class='cancelBtn' @click="hideModal">取消</div>
        </div>
    </div>
</template>
<script>
export default {
    watch: {
        changeBtnType(newVal, oldVal) {
            if (newVal === 'phone') {
                this.title = '获取手机号'
            }
        }
    },
    props: {
        changeModalType: Function,
        changeBtnType: String
    },
    mounted() {
        wx.hideTabBar()
    },
    data () {
        return {
            modalVisible: true,
            title: '登录/注册'
        }
    },
    methods: {
        getUserInfo() {
            this.$emit('getUserInfo')
        },
        getPhoneNumber() {
            this.$emit('getPhoneNumber')
        },
        hideModal () {
            this.changeModalType(false)
        }
    }
}
</script>
<style lang="scss" scoped>
.auth-wrapper {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.7);
    z-index: 10000;
    transition: all .2s ease-in-out;
    .modal {
        width: 510rpx;
        height: 510rpx;
        background: #ffffff;
        border-radius: 5px;
        .title {
            margin: 0 auto;
            text-align: center;
            line-height: 70rpx;
            color: #484848;
            font-size: 30rpx;
            border-bottom: 1rpx solid #d5d5d5;
        }
    }
    .logo {
        width: 100%;
        height: 280rpx;
        margin: 0 auto;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .loginBtn {
        width: 450rpx;
        height: 60rpx;
        background-color: #0047c8;
        color: #ffffff;
        line-height: 60rpx;
        border: none;
        border-radius: 5rpx;
        font-size: 28rpx;
        margin-bottom: 20rpx;
    }
    .cancelBtn {
        width: 450rpx;
        height: 60rpx;
        background-color: #ffffff;
        color: #2267ee;
        line-height: 60rpx;
        border: none;
        border-radius: 5rpx;
        font-size: 28rpx;
        text-align: center;
        margin: 10rpx auto;
    }
}
</style>